<?php
/**
 *	KLF Framework
 *
 *	Written by Kristian Oye <kristianoye@gmail.com> on Dec 18, 2011
 *	Copyright (C) 2010-2011
 */
namespace KLF\System\Web\MVC
{
	use KLF\System\KComponent;
	use KLF\System\Web\KHttpContext;
	use KLF\System\Collections\KDictionary;
	use KLF\System\Web\Routing\KRouteContext;
	
	/**
	 *  Class KController
	 *
	 *  The base of all MVC controller types.
	 *
	 *  @package KLF\System\Web\MVC
	 *  @access public
	 *  @author Kristian Oye <kristianoye@gmail.com>
	 *  @since 0.1
	 *
	 *  @method KController NewInstance
	 *  
	 *  @property KRouteContext $ControllerContext
	 *  @property string $Name
	 *  @property KDictionary $TempData
	 *  @property boolean $ValidateRequest 
	 */
	abstract class KBaseController extends KComponent implements IController
	{
		/**
		 * Gets or sets the current context. 
		 * 
		 * @var KRouteContext $_propControllerContext
		 */
		protected $_rpropControllerContext;
		
		/**
		 * The controller name
		 * @var string $_propName
		 */
		protected $_propName;
		
		/**
		 * Gets or sets the temporary dictionary.
		 * 
		 * @var KDictionary $_propTempData
		 */
		protected $_propTempData;
		
		/**
		 * Gets or sets a value that indicates whether request validation is enabled for this request.
		 * 
		 * @var boolean $_propValidateRequest
		 */
		protected $_propValidateRequest;
		
		/**
		 * 
		 * Enter description here ...
		 * @var unknown_type
		 */
		protected $_propValueProvider;
		
		/**
		 * Gets or sets the collection of view data.
		 * 
		 * @var KDictionary $_propViewData
		 */
		protected $_propViewData;
		
		/**
		 * Construct a new BaseController.
		 * 
		 * @param KRouteContext $context
		 * @param string $controllerName
		 */
		public function __construct(KRouteContext $context, $controllerName = '')
		{
			$this->_propName = $controllerName;
			$this->_propTempData = new KDictionary('string', null);
			$this->_propValidateRequest = true;
			$this->_propViewData = new KDictionary('string', null);
			$this->_rpropControllerContext = new KControllerContext($context, $controllerName, $this);
			
			parent::__construct();
		}
		
		protected abstract function ExecuteCore();
		
		public function Execute(KRouteContext $context)
		{
			$this->ExecuteCore();
		}
	}
}